FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

operator<<() method from fcf::NTest::TimeDuration class

std::ostream& operator<<(std::ostream& a_stream, const fcf::NTest::TimeDuration& a_td)

Class: fcf::NTest::TimeDuration

Package: fcfTest

File: test.hpp

Available from version: 1.2.5

Inserts the duration into an output stream.

The operator<< method allows for easy logging of fcf::NTest::TimeDuration objects using standard C++ streams like std::cout.

It supports a special fcf::NTest::Friendly manipulator to switch between human-readable and raw formats directly within the stream expression.

Result
std::ostream&
- Reference to the output stream.

Example: Stream insertion

Demonstrating how to print durations using the stream operator and the Friendly manipulator.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> FCF_TEST_DEFINE("TimeDemo", "Basics", "StreamInsertion") { fcf::NTest::TimeDuration d(1234567890ULL); // 1. Standard output std::cout << d << std::endl; // 2. Friendly output using the Friendly manipulator std::cout << fcf::NTest::Friendly(true) << d << std::endl; // 3. Raw output using the Friendly manipulator std::cout << fcf::NTest::Friendly(false) << d << std::endl; } int main(int a_argc, char* a_argv[]) { bool error = false; fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

Performing the test: "TimeDemo" -> "Basics" -> "StreamInsertion" ... 1234567890 1.234`567`890 1.234567890 [SUCCESS] Test completed successfully (0.000`000`000 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`000`000 sec